package com.turing.post.cardmanagement.util;

import java.io.Serializable;
import java.math.BigInteger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

import com.turing.post.util.PCPSUtil;
/**
 * 卡种类绑定商户
 * @author kz
 * @date 2012-12-17
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "CardClassicBindMerchant")
@IdClass(CardClassicBindMerchant.class)
public class CardClassicBindMerchant implements Serializable {
	/**
	 * 卡类ID
	 */
	private BigInteger cardClassicId;
	/**
	 * 商户号
	 */
	private String merchantNo;
	
	public CardClassicBindMerchant(){
		super();
	}
	
	@Id
	@Column(name = "CARDCLASSICID", nullable = false)
	public BigInteger getCardClassicId() {
		return cardClassicId;
	}
	
	public void setCardClassicId(BigInteger cardClassicId) {
		this.cardClassicId = cardClassicId;
	}

	@Id
	@Column(name = "MERCHANTNO", nullable = false)
	public String getMerchantNo() {
		return merchantNo;
	}

	public void setMerchantNo(String merchantNo) {
		this.merchantNo = merchantNo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime * result
				+ ((this.getCardClassicId() == null) ? 0 : this.getCardClassicId().hashCode());
		result = prime * result
				+ ((this.getMerchantNo() == null) ? 0 : this.getMerchantNo().hashCode());

		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof CardClassicBindMerchant))
			return false;
	
		CardClassicBindMerchant other = (CardClassicBindMerchant) obj;
		
		if ( !PCPSUtil.compareObject(this.getCardClassicId(), other.getCardClassicId()))
			return false;

		return PCPSUtil.compareObject(this.getMerchantNo(), other.getMerchantNo());
	}	
}
